function BVQXfigureCallback(cbstr, fig, cbo, setparent)
% BVQXfigure::docallback  - make sure a callback has its own workspace
%
% Since this callback is only for internal use of the BVQXfigure class
% it must not be used directly!
%
% See also @BVQXfigure

% Version:      v0.7g
% Build:        9032722
% Date:         Mar-27 2009, 10:00 PM CET
% Author:       Jochen Weber, SCAN Unit, Columbia University, NYC, NY, USA
% URL / Info:   http://wiki.brainvoyager.com/BVQXtools

% set references
try
    this = BVQXfigure(cbo);
    if ~isBVQXfigure(this, true)
        error('INVALID_HANDLE');
    end
    gcf  = fig;
    gcbf = fig;
    gcbo = cbo;
    
    % set parent?
    if nargin > 3 && ...
       ~isempty(setparent)
        parent = BVQXfigure(get(gcbo, 'Parent'));
        thisfig = BVQXfigure(gcf);
    end

    % evaluate callback
    eval(cbstr);
catch
    warning( ...
        'BVQXfigure:BadHandle', ...
        'Callback of handle failed: ''%s''.', ...
        lasterr ...
    );
end
